package com.opengit;

import java.io.File;
import java.io.IOException;

/**
 * @Description：
 * @Author: yuyd
 * @Email: yuyd3@asiainfo.com
 * @Since: 2022-07-15 18:31
 * @Version
 */
public class Test {
    private static int count = 0;

    private static int pdfCount = 0;

    public static void main(String[] args) throws IOException {
        String path = "E:\\202207";        //要遍历的路径
        File file = new File(path);        //获取其file对象
        func(file);
        System.out.println("=============处理结束========图片" + count);
        System.out.println("=============处理结束========pdf" + pdfCount);
    }

    private static void func(File file) throws IOException {
        File[] fs = file.listFiles();
        if (fs != null && fs.length > 0) {
            for (File f : fs) {
                if (f.isDirectory()) {
                    func(f);
                }
                if (f.isFile()) {
                    String absolutePath = f.getAbsolutePath();
                    /*if (f.getName().contains("jpg")) {
                        count++;
                        TiffConvert.image2Tif(absolutePath);
                    } else if (f.getName().contains("pdf")) {
                        pdfCount ++;
                        TiffConvert.pdf2Tiff(absolutePath);
                    }*/
                    if (f.getName().contains("jpg") || f.getName().contains("TIFF") || f.getName().contains("tiff")) {
                        count++;
                        TiffConvert.jpgToPdf(absolutePath);
                    }
                }
            }
        }
        System.out.println("================= 文件夹处理完成 ==============");
    }

}
